package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class BorrowOperation implements IOPeration{
    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("借阅图书！！");
        System.out.println("请输入您要借阅图书的书名：");
        String name = scanner.nextLine();

        int currentSize = bookList.books.usedSize;
        for (int i = 0; i <currentSize ; i++) {
            Book book = (Book)bookList.books.get(i);
            if (book.getName().equals(name)){
                book.setIsborrow(true);
                System.out.println("借阅成功！！");
                return;
            }
        }
        System.out.println("没有找到您要借阅的图书！！！");
        return;
    }
}
